#ifndef _FIG_FLYING_PATH_H_
#define _FIG_FLYING_PATH_H_

#include "math/vec2.h"
#include <vector>
#include <string>

class FIGEnemyPathCraft;


class FIGFlyingPath
{
public:

	enum PATH_TYPE
	{
		PATH_NONE,
		PATH_TOUNT_COUT,
		PATH_SIDE_ROTATE_LEFT,
		PATH_SIDE_ROTATE_RIGHT,
		PATH_LEFTCONER_TO_RIGHT_CONER1,
		PATH_LEFTCONER_TO_RIGHT_CONER2,		
		PATH_RIGHTCONER_TO_LEFT_CONER1,
		PATH_RIGHTCONER_TO_LEFT_CONER2,
		PATH_COMELEFT_CIRCLE,
		PATH_COMERIGHT_CIRCLE,
		PATH_DRAGON_TONT_COUNT,
		PATH_DRAGON_LEFT_TO_RIGHT,
		PATH_DRAGON_RIGHT_TO_LEFT,

		PATH_LEFT_TO_RIGHT_DIAGONAL,
		PATH_RIGHT_TO_LEFT_DIAGONAL,

		PATH_COUNT
	};
	

	struct PathPiece
	{
		float	TargetRotation;
		float	RotateSpeed;
		float	Distance;

		PathPiece() :
			TargetRotation(0),
			RotateSpeed(0),
			Distance(0)
			{
			}
	};

	struct FlyingPath
	{
		math::Vec2								m_StartPos;
		float									m_InitialRotation;
		
		std::vector<FIGFlyingPath::PathPiece*>	m_PathPieces;

		FlyingPath() : m_InitialRotation(0)
		{
		  
		}
		void	AddPathPiece(float Rotation, float RotateSpeed, float Duration);
	};

	struct PathInfo
	{
		float		Rotation;
		bool		m_IsDone;

		PathInfo()   : 
			Rotation(0),
			m_IsDone(false)
		{
			
		};
	};	


	struct CraftInfo
	{
		int		PathPieceIndex;
		float	RotationDone;
		float	DistantTravelled;

		CraftInfo() : 
						PathPieceIndex(0),
						RotationDone(0),
						DistantTravelled(0)
		{
			
		};

		void	Reset()
		{
			PathPieceIndex = 0;
			RotationDone = 0;
			DistantTravelled = 0;
		};
	};

	static FIGFlyingPath&					Instance();
	const PathInfo&							GetPosFromPath(
															PATH_TYPE PType,
															CraftInfo&	pCraftInfo,															
															float dt);

	FIGFlyingPath::FlyingPath*				GetPath(FIGEnemyPathCraft* pCraft);

	static FIGFlyingPath::PATH_TYPE			MapNameToType(const std::string& PathName);
	static std::string						MapTypeToName(FIGFlyingPath::PATH_TYPE PathType);
	

protected:

	FIGFlyingPath();
	~FIGFlyingPath();

	FIGFlyingPath::FlyingPath*					GetPathByType(FIGFlyingPath::PATH_TYPE PathType);
	

	void										Path_TontCout(FIGFlyingPath::FlyingPath*);
	
												// for dragon 
	void										Path_DragonTontCount(FIGFlyingPath::FlyingPath*);
	void										Path_DragonLeftToRight(FIGFlyingPath::FlyingPath*);
	void										Path_DragonRightToLeft(FIGFlyingPath::FlyingPath*);

	void										Path_Side_Rotate_Left(FIGFlyingPath::FlyingPath* pPath);
	void										Path_Side_Rotate_Right(FIGFlyingPath::FlyingPath* pPath);
	void										Path_LeftConer_To_RightConer1(FIGFlyingPath::FlyingPath* pPath);
	void										Path_LeftConer_To_RightConer2(FIGFlyingPath::FlyingPath* pPath);
	void										Path_RightConer_To_LeftConer1(FIGFlyingPath::FlyingPath* pPath);
	void										Path_RightConer_To_LeftConer2(FIGFlyingPath::FlyingPath* pPath);
	void										Path_ComeRight_Circle(FIGFlyingPath::FlyingPath* pPath);
	void										Path_ComeLeft_Circle(FIGFlyingPath::FlyingPath* pPath);

	void										Path_Left_To_Right_Diagonal(FIGFlyingPath::FlyingPath* pPath);
	void										Path_Right_To_Left_Diagonal(FIGFlyingPath::FlyingPath* pPath);



	PathInfo									m_PathInfo;
	FIGFlyingPath::FlyingPath*					m_FlyingPaths[PATH_COUNT];
	math::Vec2									m_TempVec2;

};



#endif
